home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 July / Disc 2 / PCU0703CD2.iso / entertn / demos / files / ron.exe / ai / scripts / economic.bhs < prev   
Encoding:
Text File  |  2003-04-29  |  33.1 KB  |  860 lines

  1. //Mark Sobota
  2. //Mike Engle
  3. //economic.bhs
  4. //boom script
  5. //general boom, good for - Aztec, Inca, Mongols, Romans, Russians, Spanish
  6.  
  7.  
  8. labels {
  9.   BLOCK_ON_THIS = 1,
  10.   DONT_BLOCK_ON_THIS,
  11.   SCRIPT_DONE,
  12. }
  13.  
  14. include "aibestbuildlibrary.bhs"
  15.  
  16. int ai economic (int who, ref int step, int boom_vs_rush, int num_loops)
  17. {
  18.   if ((num_cities(who) < 1)&&(num_type_with_queued(who, "Citizen") < 1)) return SCRIPT_DONE;
  19.  
  20.   my_capital = find_city_with_num(who, 1);
  21.  
  22.   if (was_city_attacked(who, "", -1)||was_city_raided(who, "", -1)) {
  23.     if ((num_type_with_queued(who, "Barracks") < 1)&&(have_tech(who, "The Art of War"))) {
  24.       if (place_building_with_cost(who, "Barracks", my_capital) > 0) return SCRIPT_DONE;
  25.       else return BLOCK_ON_THIS;
  26.     }
  27.     else return SCRIPT_DONE;
  28.   }
  29.  
  30.   int return_value = BLOCK_ON_THIS;
  31.   static int prev_step0 = 0;
  32.   static int prev_step1 = 0;
  33.   static int prev_step2 = 0;
  34.   static int prev_step3 = 0;
  35.   static int prev_step4 = 0;
  36.   static int prev_step5 = 0;
  37.   static int prev_step6 = 0;
  38.   static int prev_step7 = 0;
  39.   static int needed_citizens0 = 0;
  40.   static int needed_citizens1 = 0;
  41.   static int needed_citizens2 = 0;
  42.   static int needed_citizens3 = 0;
  43.   static int needed_citizens4 = 0;
  44.   static int needed_citizens5 = 0;
  45.   static int needed_citizens6 = 0;
  46.   static int needed_citizens7 = 0;
  47.   static int timer_started0 = 0;
  48.   static int timer_started1 = 0;
  49.   static int timer_started2 = 0;
  50.   static int timer_started3 = 0;
  51.   static int timer_started4 = 0;
  52.   static int timer_started5 = 0;
  53.   static int timer_started6 = 0;
  54.   static int timer_started7 = 0;
  55.   static int fishermen_total0 = 0;
  56.   static int fishermen_total1 = 0;
  57.   static int fishermen_total2 = 0;
  58.   static int fishermen_total3 = 0;
  59.   static int fishermen_total4 = 0;
  60.   static int fishermen_total5 = 0;
  61.   static int fishermen_total6 = 0;
  62.   static int fishermen_total7 = 0;
  63.   int old_step;
  64.   who_nation = find_nation(who); //get player nation
  65.   static int needed_techs = get_techs_per_age(who);
  66.   int player_age = age(who);
  67.   static int wood_camp = 0;
  68.   static int wood_camp_1 = 0;
  69.   static int max_woodcutters = 0;
  70.   int needed_citizens = 0;
  71.   static int build_merchant = 0;
  72.   int timer_started = 0;
  73.   int j = 0;
  74.   int merchant_build_true = 1;
  75.   int scholar_build_true = 1;
  76.   int build_true = 1;
  77.   int new_city = 0;
  78.   int citizen_id = 0;
  79.   int caravan_lim = num_cities(who) * (num_cities(who) - 1) / 2;
  80.   int fishermen_cap = 4;
  81.   int fishermen_total = 0;
  82.   int large_conquest_start = 0;
  83.  
  84.   int sea_map = 0;
  85.  
  86.   ///ghetto array///
  87.   switch (who-1) {
  88.   case 0:
  89.     old_step = prev_step0;
  90.     needed_citizens = needed_citizens0;
  91.     timer_started = timer_started0;
  92.     fishermen_total = fishermen_total0;
  93.     break;
  94.   case 1:
  95.     old_step = prev_step1;
  96.     needed_citizens = needed_citizens1;
  97.     timer_started = timer_started1;
  98.     fishermen_total = fishermen_total1;
  99.     break;
  100.   case 2:
  101.     old_step = prev_step2;
  102.     needed_citizens = needed_citizens2;
  103.     timer_started = timer_started2;
  104.     fishermen_total = fishermen_total2;
  105.     break;
  106.   case 3:
  107.     old_step = prev_step3;
  108.     needed_citizens = needed_citizens3;
  109.     timer_started = timer_started3;
  110.     fishermen_total = fishermen_total3;
  111.     break;
  112.   case 4:
  113.     old_step = prev_step4;
  114.     needed_citizens = needed_citizens4;
  115.     timer_started = timer_started4;
  116.     fishermen_total = fishermen_total4;
  117.     break;
  118.   case 5:
  119.     old_step = prev_step5;
  120.     needed_citizens = needed_citizens5;
  121.     timer_started = timer_started5;
  122.     fishermen_total = fishermen_total5;
  123.     break;
  124.   case 6:
  125.     old_step = prev_step6;
  126.     needed_citizens = needed_citizens6;
  127.     timer_started = timer_started6;
  128.     fishermen_total = fishermen_total6;
  129.     break;
  130.   case 7:
  131.     old_step = prev_step7;
  132.     needed_citizens = needed_citizens7;
  133.     timer_started = timer_started7;
  134.     fishermen_total = fishermen_total7;
  135.     break;
  136.   default:
  137.     old_step = 0;
  138.     needed_citizens = 0;
  139.     break;
  140.   }
  141.  
  142.   ////water mapstyles at the moment: Atlantic Sea Power, Nile Delta, British Isles, Warring States, New World, East Indies
  143.   //// Colonial Powers, Mediterranean
  144.   ////Great Lakes?, African Watering Hole?, East Meets West?, Australian Outback?
  145.   if ((get_mapstyle() == "Atlantic Sea Power")||(get_mapstyle() == "Nile Delta")||(get_mapstyle() == "British Isles")||(get_mapstyle() == "Warring States")||(get_mapstyle() == "New World")||(get_mapstyle() == "East Indies")) {
  146.     sea_map = 1;
  147.   }
  148.   else if ((get_mapstyle() == "Colonial Powers")||(get_mapstyle() == "Mediterranean")) {
  149.     sea_map = 1;
  150.   }
  151.   else sea_map = 0;
  152.  
  153.   my_second_city = find_city_with_num(who, 2);
  154.   my_third_city = find_city_with_num(who, 3);
  155.  
  156.   if (is_conquest_scenario()) {
  157.     size = get_starting_town_size(who);
  158.     if (step == 1) {
  159.       if (size == 0) step = 1; //nomad
  160.       else if (size == 1) step = 2;
  161.       else if (size == 2) {
  162.         if (sea_map > 0) step = 6; //sea boom
  163.         else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 7;
  164.         else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 7;
  165.         else step = 6; //standard
  166.       }
  167.       else large_conquest_start = 1;
  168.     }
  169.     else if (size > 2) large_conquest_start = 1;
  170.   }
  171.   if (large_conquest_start > 0) {
  172.     if ((age(who) > 0)&&(age(who) < 5)) {
  173.       //build 2 farms, university, mine, 2nd woodcutter, research military 1, build barracks, build stable, 2 heavy, 2 light, 1 archer
  174.       switch (step) {
  175.       case 1:
  176.         if(!have_tech(who, "The Art of War")) {
  177.           if (research_tech_with_cost(who, "The Art of War") > 0) step++;
  178.         }
  179.         else step++;
  180.         return BLOCK_ON_THIS;
  181.         break;
  182.       case 2:
  183.         train_unit_with_cost(who, 5, "Citizen");
  184.         if (have_tech(who, "The Art of War")) step+=2;
  185.         else step++;
  186.         return BLOCK_ON_THIS;
  187.         break;
  188.       case 3:
  189.         if (num_type_with_queued(who, "Barracks") < 1) {
  190.           if (num_cities(who) == 1) place_building_upgrade_with_cost(who, "Barracks", my_capital);
  191.           else if (num_cities(who) == 2) place_building_upgrade_with_cost(who, "Barracks", my_second_city);
  192.           else if (num_cities(who) == 3) place_building_upgrade_with_cost(who, "Barracks", my_third_city);
  193.         }
  194.         if (num_type_with_queued(who, "Stable") < 1) {
  195.           if (num_cities(who) == 1) place_building_upgrade_with_cost(who, "Stable", my_capital);
  196.           else if (num_cities(who) == 2) place_building_upgrade_with_cost(who, "Stable", my_second_city);
  197.           else if (num_cities(who) == 3) place_building_upgrade_with_cost(who, "Stable", my_third_city);
  198.         }
  199.         if ((num_type_with_queued(who, "Barracks") > 0)&&(num_type_with_queued(who, "Stable") > 0)) step++;
  200.         return BLOCK_ON_THIS;
  201.         break;
  202.       case 4:
  203.         if (num_type_with_queued(who, "Tower") < num_cities(who)) {
  204.           if (num_cities(who) == 1) place_building_upgrade_with_cost(who, "Tower", my_capital);
  205.           else if (num_cities(who) == 2) {
  206.             place_building_upgrade_with_cost(who, "Tower", my_second_city);
  207.             place_building_upgrade_with_cost(who, "Tower", my_capital);
  208.           }
  209.           else if (num_cities(who) == 3) {
  210.             place_building_upgrade_with_cost(who, "Tower", my_third_city);
  211.             place_building_upgrade_with_cost(who, "Tower", my_second_city);
  212.             place_building_upgrade_with_cost(who, "Tower", my_capital);
  213.           }
  214.         }
  215.         else if (num_type(who, "Market") < 1) return SCRIPT_DONE;
  216.         if (num_type_with_queued(who, "Tower") > num_cities(who)-1) return SCRIPT_DONE;
  217.         return BLOCK_ON_THIS;
  218.         break;
  219.       default:
  220.         return SCRIPT_DONE;
  221.       }
  222.     }
  223.     else if (age(who) > 4) {
  224.       switch (step) {
  225.       case 1:
  226.         if(!have_tech(who, "The Art of War")) {
  227.           if (research_tech_with_cost(who, "The Art of War") > 0) step++;
  228.         }
  229.         else step++;
  230.         return BLOCK_ON_THIS;
  231.         break;
  232.       case 2:
  233.         train_unit_with_cost(who, 5, "Citizen");
  234.         if (have_tech(who, "The Art of War")) step+=2;
  235.         else step++;
  236.         return BLOCK_ON_THIS;
  237.         break;
  238.       case 3:
  239.         if (num_type_with_queued(who, "Barracks") < 1) {
  240.           if (num_cities(who) == 1) place_building_upgrade_with_cost(who, "Barracks", my_capital);
  241.           else if (num_cities(who) == 2) place_building_upgrade_with_cost(who, "Barracks", my_second_city);
  242.           else if (num_cities(who) == 3) place_building_upgrade_with_cost(who, "Barracks", my_third_city);
  243.         }
  244.         if (num_type_with_queued(who, "Auto Plant") < 1) {
  245.           if (num_cities(who) == 1) place_building_upgrade_with_cost(who, "Auto Plant", my_capital);
  246.           else if (num_cities(who) == 2) place_building_upgrade_with_cost(who, "Auto Plant", my_second_city);
  247.           else if (num_cities(who) == 3) place_building_upgrade_with_cost(who, "Auto Plant", my_third_city);
  248.         }
  249.         if ((num_type_with_queued(who, "Barracks") > 0)&&(num_type_with_queued(who, "Auto Plant") > 0)) step++;
  250.         return BLOCK_ON_THIS;
  251.         break;
  252.       case 4:
  253.         if (num_type_with_queued(who, "Stockade") < num_cities(who)) {
  254.           if (num_cities(who) == 1) place_building_upgrade_with_cost(who, "Tower", my_capital);
  255.           else if (num_cities(who) == 2) {
  256.             place_building_upgrade_with_cost(who, "Tower", my_second_city);
  257.             place_building_upgrade_with_cost(who, "Tower", my_capital);
  258.           }
  259.           else if (num_cities(who) == 3) {
  260.             place_building_upgrade_with_cost(who, "Tower", my_third_city);
  261.             place_building_upgrade_with_cost(who, "Tower", my_second_city);
  262.             place_building_upgrade_with_cost(who, "Tower", my_capital);
  263.           }
  264.         }
  265.         else if (num_type(who, "Market") < 1) return SCRIPT_DONE;
  266.         if (num_type_with_queued(who, "Tower") > num_cities(who)-1) return SCRIPT_DONE;
  267.         return BLOCK_ON_THIS;
  268.         break;
  269.       default:
  270.         return SCRIPT_DONE;
  271.       }
  272.     }
  273.   }
  274.  
  275.   if (step == 1) {
  276.     if (get_starting_resources(who) > 4 || num_cities(who) > 1) {
  277.       return SCRIPT_DONE;
  278.     }
  279.     size = get_starting_town_size(who);
  280.     if (size == 0) step = 1; //nomad
  281.     else if (size == 1) step = 2;
  282.     else if (size >= 2) {
  283.       if (sea_map > 0) step = 6; //sea boom
  284.       else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 7;
  285.       else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 7;
  286.       else step = 6; //standard
  287.     }
  288.     else return SCRIPT_DONE;
  289.   }
  290.  
  291.   train_unit_with_need(who, needed_citizens, "Citizen");
  292.  
  293.   ////builds needed number of caravans and merchants
  294.   if (num_type(who, "Market") >= 1) {
  295.     if (num_type_with_queued(who, "Caravan") < caravan_lim) {
  296.       train_unit_with_cost(who, 1, "Caravan");  
  297.     }
  298.     if (at_least_type(who, 100, "Wealth")) {
  299.       for (j = num_type_with_queued(who, "Merchant"); ((j < 3)&&(j < num_rare_resources_seen(who))); j++) {
  300.         if (train_unit_with_cost(who, 1, "Merchant") < 1) break;
  301.       }
  302.     }
  303.   }
  304.  
  305.   //checks pop limit
  306.   if (population(who) >= 23 && (!have_tech(who, "The Art of War"))) {
  307.     research_tech_with_cost(who, "The Art of War");
  308.   }
  309.  
  310.   //spend all gold on scholars
  311.   //at_least_type(const int &who, const int &num, const String &type)
  312.   if ((num_type(who, "University") > 0)&&((num_type(who, "Market") > 0)||(num_type(who, "Dock") > 0))) {
  313.     if (at_least_type(who, 130, "Wealth")) {
  314.       train_unit_with_cost(who, 1, "Scholar");
  315.     }
  316.   }
  317.  
  318.   //builds fish herders after dock is built
  319.   if ((fishermen_total < fishermen_cap)&&(num_type(who, "Dock") > 0)&&(at_least_type(who, 100, "Timber"))) {
  320.     if (train_unit_with_cost(who, 1, "Fishermen") > 0) fishermen_total++;
  321.   }
  322.  
  323.   //builds tower after military I is researched
  324.   if ((have_tech(who, "The Art of War"))&&(num_type_with_queued(who, "Tower") < 1)) {
  325.     if (num_cities(who) > 1) {
  326.       place_building_with_cost(who, "Tower", my_second_city);
  327.     }
  328.     else {
  329.       place_building_with_cost(who, "Tower", my_capital);
  330.     }
  331.   }
  332.  
  333.   if ((num_type(who, "Tower") > 0)&&(!have_tech(who, "Allegiance"))&&(age(who) > 0)&&(have_tech(who, "Mathematics"))) {
  334.     research_tech_with_cost(who, "Allegiance");
  335.   }
  336.  
  337.   ////check to see if script is hanging
  338.   if ((step == old_step)&&(timer_started < 1)) {
  339.     set_timer(who, 300);
  340.     timer_started = 1;
  341.   }
  342.  
  343.   if (step != old_step) {
  344.     stop_timer(who);
  345.     timer_started = 0;
  346.   }
  347.  
  348.   if (timer_expired(who)) {
  349.     return SCRIPT_DONE;
  350.   }
  351.   
  352.   for (i = 0; i < num_loops; i++) {
  353.  
  354.     if (old_step != step) old_step = step;
  355.  
  356.     switch (step) {
  357.     ////Nomad Setup Procedure/////
  358.     case 1: //place City (nomad)
  359.       old_step = 0;
  360.       if (num_type_with_queued(who, "Small City") < 1) place_city_with_cost(who);
  361.       if (find_inactive_build(who, "Small City")) {
  362.         new_city = find_inactive_build(who, "Small City");
  363.         if (building_started(who, new_city)) step++;
  364.       }
  365.       return_value = BLOCK_ON_THIS;
  366.       break;
  367.     case 2: //place Woodcutter's Camp at capital
  368.       old_step = 0;
  369.       new_city = find_inactive_build(who, "Small City");
  370.       if (new_city > 0) {
  371.         for (j = 0; j < num_type(who, "Citizen"); j++) {
  372.           citizen_id = find_unit(who, "Citizen");
  373.           citizen_repair_order(who, citizen_id, new_city);
  374.         }
  375.       }
  376.       if (place_building_with_cost(who, "Woodcutter's Camp", my_capital) > 0) step++;
  377.       else if ((my_capital > -1) && (can_pay_cost(who, "Woodcutter's Camp") > 0)) return SCRIPT_DONE;
  378.       return_value = BLOCK_ON_THIS;
  379.       break;
  380.     case 3: //place 3 farms at capital
  381.       old_step = 0;
  382.       for (j = num_type_with_queued(who, "Farm"); j < 3; j++) {
  383.         if (place_building_with_cost(who, "Farm", my_capital) < 1) break;
  384.       }
  385.       if (num_type_with_queued(who, "Farm") == 3) step++;
  386.       return_value = BLOCK_ON_THIS;
  387.       break;
  388.     case 4: //build up to 5 peasants
  389.       needed_citizens = 5;
  390.       train_unit_with_need(who, needed_citizens, "Citizen");
  391.       if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)) {
  392.         if (num_type_with_queued(who, "University") > 0) step++;
  393.         else if (place_building_with_cost(who, "University", my_capital) > 0) step++;
  394.       }
  395.       else step++;
  396.       return_value = BLOCK_ON_THIS;
  397.       break;
  398.     case 5: //build a library
  399.       old_step = 0;
  400.       if (place_building_with_cost(who, "Library", my_capital) > 0) {
  401.         if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)) step = 7;
  402.         else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 7;
  403.         else {
  404.           if(at_least_type(who, 75, "Wealth") < 1) step = 7;
  405.           else step++;
  406.         }
  407.       }
  408.       return_value = BLOCK_ON_THIS;
  409.       break;
  410.     ////End Nomad Setup Procedure/////
  411.     case 6: //Science I
  412.       old_step = 0;
  413.       if (!have_tech(who, "Written Word")) {
  414.         if (research_tech_with_cost(who, "Written Word") > 0) {
  415.           if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 18;
  416.           else step++; 
  417.         }
  418.         else {
  419.           if(at_least_type(who, 75, "Wealth") < 1) step++;
  420.         }
  421.       }
  422.       else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 18;
  423.       else step++;
  424.       return_value = BLOCK_ON_THIS;
  425.       break;
  426.     case 7: //Civic I
  427.       if (num_cities(who) > 1) return SCRIPT_DONE;
  428.       else if (have_tech(who, "City State")) step++;
  429.       else if (research_tech_with_cost(who, "City State")) step++;
  430.       return_value = BLOCK_ON_THIS;
  431.       break;
  432.     case 8: //Build 4 Citizens -> Timber.
  433.       needed_citizens = 9;
  434.       train_unit_with_need(who, needed_citizens, "Citizens");
  435.       step++;
  436.       return_value = BLOCK_ON_THIS;
  437.       break;
  438.     case 9: //Build a Farm with a Woodcutter.
  439.       if (place_farm(who) >= 0) step++;
  440.       return_value = BLOCK_ON_THIS;
  441.       break;
  442.     case 10: //Build City #2 with a Woodcutter.
  443.       if (have_tech(who, "City State")) {
  444.         if (num_cities(who) < 2) {
  445.           if (city_placement(who) > 0) {
  446.             if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 10;
  447.             else step++;
  448.           }
  449.         }
  450.         else {
  451.           if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) {
  452.             if (num_cities(who) < 3) {
  453.               if (city_placement(who) > 0) step++;
  454.             }
  455.             else step++;
  456.           }
  457.           else step++;
  458.         }
  459.       }
  460.       return_value = BLOCK_ON_THIS;
  461.       break;
  462.     case 11: //Build 2 Citizens -> Timber.
  463.       needed_citizens = 11;
  464.       train_unit_with_need(who, needed_citizens, "Citizens");
  465.       step++;
  466.       return_value = BLOCK_ON_THIS;
  467.       break;
  468.     case 12: //Build a Farm with a Woodcutter.
  469.       if (place_farm(who) >= 0) {
  470.         if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 14;
  471.         else step++;
  472.       }
  473.       return_value = BLOCK_ON_THIS;
  474.       break;
  475.     case 13: //Build Woodcutter #2
  476.       if (place_woodcutter(who) >= 0) {
  477.         if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 17;
  478.         else step++;
  479.       }
  480.       return_value = BLOCK_ON_THIS;
  481.       break;
  482.     case 14: //Commerce I
  483.       if (research_tech_with_cost(who, "Barter") > 0) {
  484.         if (sea_map > 0) step = 35;//build a dock
  485.         else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 17;
  486.         else if ((who_nation == "Koreans")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step+=2;
  487.         else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 13;
  488.         else step++;
  489.       }
  490.       return_value = BLOCK_ON_THIS;
  491.       break;
  492.     case 15: //Build Market #1 (then immediately build a Caravan)
  493.       if (num_city_buildings(who, my_capital, "Market", 1) < 1) {
  494.         if (have_tech(who, "Barter")) {
  495.           if (place_building_with_cost(who, "Market", my_capital) > 0) {
  496.             if (sea_map > 0) step = 18;
  497.             else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 23;
  498.             else if ((who_nation == "Koreans")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step+=2;
  499.             else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 18;
  500.             else step++;
  501.           }
  502.         }
  503.       }
  504.       else {
  505.         if (sea_map > 0) step = 18;
  506.         else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 23;
  507.         else if ((who_nation == "Koreans")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step+=2;
  508.         else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 18;
  509.         else step++;
  510.       }
  511.       return_value = BLOCK_ON_THIS;
  512.       break;
  513.     case 16: //Build 3 Citizens -> Timber.
  514.       needed_citizens = 14;
  515.       train_unit_with_need(who, needed_citizens, "Citizens");
  516.       if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 15;
  517.       else step++;
  518.       return_value = BLOCK_ON_THIS;
  519.       break;
  520.     case 17: //construct 2 Farms.
  521.       //got 5 already
  522.       old_step = 0;
  523.       if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) {
  524.         needed_citizens = 23;
  525.         if (num_type_with_queued(who, "Farm") < 10) {
  526.           if (place_farm(who) > 0) old_step = 0;
  527.         }
  528.         else step = 28;
  529.       }
  530.       else if (num_type_with_queued(who, "Farm") < 7) place_farm(who);
  531.       else {
  532.         if (sea_map > 0) step = 23;
  533.         else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 20;
  534.         else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 16;
  535.         else step++;
  536.       }
  537.       return_value = BLOCK_ON_THIS;
  538.       break;
  539.     case 18: //Classical Age
  540.       if ((is_conquest_scenario())&&(age(who) > 0)) {
  541.           if (sea_map > 0) step = 24;
  542.           else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 29;
  543.           else if ((who_nation == "Egyptians")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step+=2;
  544.           else if ((who_nation == "Inca")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step+=2;
  545.           else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 20;
  546.           else step++;
  547.       }
  548.       else if (needed_techs <= 3) {
  549.         if (age(who) > 0) return SCRIPT_DONE;
  550.         else if (research_tech_with_cost(who, "Classical Age") > 0) {
  551.           if (sea_map > 0) step = 24;
  552.           else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 29;
  553.           else if ((who_nation == "Egyptians")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step+=2;
  554.           else if ((who_nation == "Inca")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step+=2;
  555.           else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 20;
  556.           else step++;
  557.         }
  558.       }
  559.       else return SCRIPT_DONE;
  560.       return_value = BLOCK_ON_THIS;
  561.       break;
  562.     case 19: //Market #2
  563.       if (num_city_buildings(who, my_second_city, "Market", 1) < 1) {
  564.         if (have_tech(who, "Barter")) {
  565.           if (place_building_with_cost(who, "Market", my_second_city) > 0) {
  566.             if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 21;
  567.             else step++;
  568.           }
  569.         }
  570.       }
  571.       else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 21;
  572.       else step++;
  573.       return_value = BLOCK_ON_THIS;
  574.       break;
  575.     case 20: //Build 2 universities and spend all Wealth on Scholars.
  576.       if (have_tech(who, "Classical Age")||((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1))) {
  577.         if (num_city_buildings(who, my_second_city, "University", 1) < 1) {
  578.           if (place_building_with_cost(who, "University", my_second_city) == 0) return SCRIPT_DONE;
  579.           old_step = 0;
  580.         }
  581.         else if (num_city_buildings(who, my_capital, "University", 1) < 1) {
  582.           if (place_building_with_cost(who, "University", my_capital) == 0) return SCRIPT_DONE;
  583.           old_step = 0;
  584.         }
  585.         else {
  586.           if (sea_map > 0) step = 30;
  587.           else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 15;
  588.           else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 32;
  589.           else step++;
  590.         }
  591.       }
  592.       else if (researching_tech(who, "Classical Age") > 0) old_step = 0;
  593.       return_value = BLOCK_ON_THIS;
  594.       break;
  595.     case 21: //Build Mine #1.
  596.       if (place_mine(who) >= 0) {
  597.         if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 29;
  598.         else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 32;
  599.         else if ((who_nation == "Inca")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) {
  600.           //build two more mines
  601.           old_step = 0;
  602.           if (num_type_with_queued(who, "Mine") < 3) place_mine(who);
  603.           else step++;
  604.           if (can_pay_cost(who, "Mine") > 0) step++;          
  605.         }
  606.         else step++;
  607.       }
  608.       return_value = BLOCK_ON_THIS;
  609.       break;
  610.     case 22: //Build 9 Citizens
  611.       old_step = 0;
  612.       if ((who_nation == "Inca")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) needed_citizens = 27;
  613.       else needed_citizens = 23;
  614.       train_unit_with_need(who, needed_citizens, "Citizens");
  615.       if (sea_map > 0) step = 32;
  616.       else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 33;
  617.       else step++;
  618.       return_value = BLOCK_ON_THIS;
  619.       break;
  620.     case 23: //Commerce II
  621.       old_step = 0;
  622.       if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) needed_citizens = 18;
  623.       if(!have_tech(who, "Coinage")) {
  624.         if (research_tech_with_cost(who, "Coinage") > 0) {
  625.           if (sea_map > 0) step = 15;
  626.           else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 25;
  627.           else step++;
  628.         }
  629.       }
  630.       else {
  631.         if (sea_map > 0) step = 15;
  632.         else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 25;
  633.         else step++;
  634.       }
  635.       return_value = BLOCK_ON_THIS;
  636.       break;
  637.     case 24: //Military I
  638.       if (!have_tech(who, "The Art of War")) {
  639.         if (research_tech_with_cost(who, "The Art of War")) {
  640.           if (sea_map > 0) step = 29;
  641.           else if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 31;
  642.           else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) {
  643.             needed_citizens = 20;
  644.             step++;
  645.           }
  646.           else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 34;
  647.           else step++;
  648.         }
  649.       }
  650.       else {
  651.         if (sea_map > 0) step = 29;
  652.         else if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 31;
  653.         else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) {
  654.           needed_citizens = 20;
  655.           step++;
  656.         }
  657.         else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 34;
  658.         else step++;
  659.       }
  660.       return_value = BLOCK_ON_THIS;
  661.       break;
  662.     case 25: //Build 2 Farms (Build 4 if Egyptian)
  663.       //got 7 already
  664.       if ((who_nation == "Egyptians")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) {
  665.         if (num_type_with_queued(who, "Farm") < 11) {
  666.           if (place_farm(who) > 0) old_step = 0;
  667.         }
  668.         else step++;
  669.       }
  670.       else {
  671.         if (num_type_with_queued(who, "Farm") < 9) {
  672.           if (place_farm(who) > 0) old_step = 0;
  673.         }
  674.         else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 6;
  675.         else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 24;
  676.         else step++;
  677.       }
  678.       return_value = BLOCK_ON_THIS;
  679.       break;
  680.     case 26: ///Build Granary at City #1.
  681.       if (num_city_buildings(who, my_capital, "Granary", 1) < 1) {
  682.         if (place_building_with_cost(who, "Granary", my_capital) > 0) {
  683.           if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) return SCRIPT_DONE;
  684.           else step++;
  685.         }
  686.       }
  687.       else {
  688.         if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) return SCRIPT_DONE;
  689.         else step++;
  690.       }
  691.       return_value = BLOCK_ON_THIS;
  692.       break;
  693.     case 27: //Build 5 Citizens -> Metal/Timber
  694.       needed_citizens = 28;
  695.       train_unit_with_need(who, needed_citizens, "Citizens");
  696.       step++;
  697.       return_value = BLOCK_ON_THIS;
  698.       break;
  699.     case 28: //Science II
  700.       if (!have_tech(who, "Mathematics")) {
  701.         if (research_tech_with_cost(who, "Mathematics") > 0) {
  702.           if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 24;
  703.           else step++;
  704.         }
  705.       }
  706.       return_value = BLOCK_ON_THIS;
  707.       break;
  708.     case 29: //Civic II
  709.       if (!have_tech(who, "Empire")) {
  710.         if (research_tech_with_cost(who, "Empire") > 0) {
  711.           if (sea_map > 0) step = 20;
  712.           else step++;
  713.         }
  714.       }
  715.       return_value = BLOCK_ON_THIS;
  716.       break;
  717.     case 30: //Build City #3.
  718.       if (have_tech(who, "Empire")) {
  719.         if ((num_cities(who) < 3)||((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(num_cities(who) < 4)&&(sea_map > 0))) {
  720.           if (city_placement(who) > 0) {
  721.             if (sea_map > 0) {
  722.               if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(num_type_with_queued(who, "Small City") < 4)) step = 30;
  723.               else step = 21;
  724.             }
  725.             else if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 26;
  726.             else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 21;
  727.             else step++;
  728.           }
  729.         }
  730.         else {
  731.           if (sea_map > 0) step = 21;
  732.           else if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 26;
  733.           else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 21;
  734.           else step++;
  735.         }
  736.       }
  737.       return_value = BLOCK_ON_THIS;
  738.       break;
  739.     case 31: //barracks
  740.       if (place_building_with_cost(who, "Barracks", my_second_city) > 0) {
  741.         if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 18;
  742.         else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) return SCRIPT_DONE;
  743.         else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) return SCRIPT_DONE;
  744.         else step++;
  745.       }
  746.       return_value = BLOCK_ON_THIS;
  747.       break;
  748.     case 32: //Build University #3
  749.       if (num_cities(who) > 2) {
  750.         if (num_city_buildings(who, my_third_city, "University", 1) < 1) {
  751.           if (place_building_with_cost(who, "University", my_third_city) > 0) {
  752.             if (sea_map > 0) return SCRIPT_DONE;
  753.             else if ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 31;
  754.             else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 23;
  755.             else step++;
  756.           }
  757.         }
  758.       }
  759.       return_value = BLOCK_ON_THIS;
  760.       break;
  761.     case 33: //Build Market #3 (This will be Market #2 for Egyptians)
  762.       if (num_city_buildings(who, my_third_city, "Market", 1) < 1) {
  763.         if (have_tech(who, "Barter")) {
  764.           if (place_building_with_cost(who, "Market", my_third_city) > 0) {
  765.             if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 31;
  766.             else step++;
  767.           }
  768.         }
  769.       }
  770.       else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 31;
  771.       else step++;
  772.       return_value = BLOCK_ON_THIS;
  773.       break;
  774.     case 34: //Build Woodcutter's Camp #3 (unless more than 6 open slots already exist,in which case build more citizens)
  775.       if (place_woodcutter(who) >= 0) {
  776.         if ((who_nation == "Mongols")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 36;
  777.         else if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)&&(sea_map < 1)) step = 19;
  778.         else return SCRIPT_DONE;
  779.       }
  780.       return_value = BLOCK_ON_THIS;
  781.       break;
  782.     case 35:
  783.       //dock step
  784.       if (place_dock(who) > 0) step = 16;
  785.       else if (can_pay_cost(who, "Dock") > 0) return SCRIPT_DONE;
  786.       return_value = BLOCK_ON_THIS;
  787.       break;
  788.     case 36:
  789.       //Mongolians step
  790.       if (num_type_with_queued(who, "Stable") < 2) {
  791.         if (num_cities(who) == 1) place_building_with_cost(who, "Stable", my_capital);
  792.         else if (num_cities(who) == 2) place_building_with_cost(who, "Stable", my_second_city);
  793.         else if (num_cities(who) == 3) place_building_with_cost(who, "Stable", my_third_city);
  794.         else return SCRIPT_DONE;
  795.       }
  796.       else return SCRIPT_DONE;
  797.       return_value = BLOCK_ON_THIS;
  798.       break;
  799.     default:
  800.       return_value = SCRIPT_DONE;
  801.       break;
  802.     }
  803.   }
  804.   ///ghetto array///
  805.   switch (who-1) {
  806.   case 0:
  807.     prev_step0 = old_step;
  808.     needed_citizens0 = needed_citizens;
  809.     timer_started0 = timer_started;
  810.     fishermen_total0 = fishermen_total;
  811.     break;
  812.   case 1:
  813.     prev_step1 = old_step;
  814.     needed_citizens1 = needed_citizens;
  815.     timer_started1 = timer_started;
  816.     fishermen_total1 = fishermen_total;
  817.     break;
  818.   case 2:
  819.     prev_step2 = old_step;
  820.     needed_citizens2 = needed_citizens;
  821.     timer_started2 = timer_started;
  822.     fishermen_total2 = fishermen_total;
  823.     break;
  824.   case 3:
  825.     prev_step3 = old_step;
  826.     needed_citizens3 = needed_citizens;
  827.     timer_started3 = timer_started;
  828.     fishermen_total3 = fishermen_total;
  829.     break;
  830.   case 4:
  831.     prev_step4 = old_step;
  832.     needed_citizens4 = needed_citizens;
  833.     timer_started4 = timer_started;
  834.     fishermen_total4 = fishermen_total;
  835.     break;
  836.   case 5:
  837.     prev_step5 = old_step;
  838.     needed_citizens5 = needed_citizens;
  839.     timer_started5 = timer_started;
  840.     fishermen_total5 = fishermen_total;
  841.     break;
  842.   case 6:
  843.     prev_step6 = old_step;
  844.     needed_citizens6 = needed_citizens;
  845.     timer_started6 = timer_started;
  846.     fishermen_total6 = fishermen_total;
  847.     break;
  848.   case 7:
  849.     prev_step7 = old_step;
  850.     needed_citizens7 = needed_citizens;
  851.     timer_started7 = timer_started;
  852.     fishermen_total7 = fishermen_total;
  853.     break;
  854.   default:
  855.     old_step = 0;
  856.     needed_citizens = 0;
  857.     break;
  858.   }
  859.   return return_value;
  860. }